<?php
/*由bean脚本生成 powerBy--joe*/
namespace app\common\manage;
use app\common\validate\SystemRechargeValidate;
use app\common\model\SystemRechargeModel;
use app\common\bean\SystemRechargeBean;
use app\common\bean\ListMap;
use app\common\utils\TimeUtil;
use app\common\exception\MyException;
use Exception;
class SystemRechargeManage extends BaseManage
{
	/**
	* @return SystemRechargeManage
	*/
	static function getInstance(){
		return parent::getInstance();
	}
	
	/**
	 * @desc 获取分页数据
	 * @param ListMap $listMap
	 * @return ListMap $listMap
	 * @throws Exception
	**/
	public function getPaginatorList(ListMap $listMap) {
		$conditionMap = new ListMap();
		if($timeArray = TimeUtil::getInstance()->dealBetweenTime($listMap))
		$conditionMap->setParameter(SystemRechargeBean::$alias.POINST.SystemRechargeBean::$createdAt,$timeArray);
		$conditionMap->setAlias(SystemRechargeBean::$alias);
		$listMap->setField(SystemRechargeBean::$alias.ALL_FIELD);
		!$this->getParamBool($listMap,"orderFieldName") ?: $conditionMap->setOrder($listMap->getParameter('orderFieldName').SPACE.$listMap->getParameter('orderType'));
		// Todo:添加业务处理代码...


		//自行选择是连表查询还是单表查询,默认单表
		//$resultMap = SystemRechargeModel::getInstance()->getJoinList($conditionMap);
		$resultMap = SystemRechargeModel::getInstance()->getList($conditionMap);
		$resultMap?:MyException::throwMyException("查询数据失败");
		return $resultMap;
	}
	
	/**
	 * @desc 添加数据
	 * @param SystemRechargeBean $systemRechargeBean
	 * @return int int
	 * @throws Exception
	**/
	public function add($systemRechargeBean) {
		SystemRechargeValidate::getInstance()->goCheck(SystemRechargeValidate::$add,$systemRechargeBean->getData());
		// Todo:添加业务处理代码...


		$systemRechargeBean->setCreatedAt(TimeUtil::getInstance()->getTimeNow());
		$result = SystemRechargeModel::getInstance()->addDataGetInsertId($systemRechargeBean->getData());
		$result ?: MyException::throwMyException("插入数据失败");
		return $result;
	}
	
	/**
	 * @desc 编辑数据
	 * @param SystemRechargeBean $systemRechargeBean
	 * @return int int
	 * @throws Exception
	**/
	public function edit($systemRechargeBean) {
		SystemRechargeValidate::getInstance()->goCheck(SystemRechargeValidate::$edit,$systemRechargeBean->getData());
		// Todo:添加业务处理代码...


		$result = SystemRechargeModel::getInstance()->updatedData([SystemRechargeBean::$id => $systemRechargeBean->getId()],$systemRechargeBean->getData());
		$result ?: MyException::throwMyException("更新失败");
		return $result;
	}
	
	/**
	 * @desc 删除数据
	 * @param SystemRechargeBean $systemRechargeBean
	 * @return int int
	 * @throws Exception
	**/
	public function delete($systemRechargeBean) {
		SystemRechargeValidate::getInstance()->goCheck(SystemRechargeValidate::$pkId,$systemRechargeBean->getData());
		// Todo:添加业务处理代码...


		$result = SystemRechargeModel::getInstance()->deleteData([SystemRechargeBean::$id => $systemRechargeBean->getId()]);
		$result ?: MyException::throwMyException("删除失败");
		return $result;
	}
	
	/**
	 * @desc 根据主建获取数据
	 * @param SystemRechargeBean $systemRechargeBean
	 * @return SystemRechargeBean $systemRechargeBean
	 * @throws Exception
	**/
	public function getInfo($systemRechargeBean) {
		SystemRechargeValidate::getInstance()->goCheck(SystemRechargeValidate::$pkId,$systemRechargeBean->getData());
		// Todo:添加业务处理代码...


		$result = SystemRechargeModel::getInstance()->selectData([SystemRechargeBean::$id => $systemRechargeBean->getId()]);
		$result ?: MyException::throwMyException("获取信息失败");
		$systemRechargeBean->setData($result);
		return $systemRechargeBean;
	}
}
